package com.gehj.androidlibs;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentStatePagerAdapter;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;

import com.gehj.androidlibs.fragments.SplashFragment;
import com.gehj.androidlibs.transform.ScaleTransformer;

import org.jetbrains.annotations.NotNull;

public class SplashActivity extends AppCompatActivity {
    private ViewPager viewPager;
    //IMPORTANT:大尺寸图片要放到xxdpi的drawable或者mipmap下
    private int[] mResIds = new int[]{
            R.drawable.start1,
            R.drawable.start2,
            R.drawable.start3,
    };



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        viewPager = findViewById(R.id.vp_main);
        viewPager.setAdapter(new FragmentStatePagerAdapter(getSupportFragmentManager()) {
            @NotNull
            @Override
            public Fragment getItem(int position) {
                return SplashFragment.newInstant(mResIds[position]);
            }

            @Override
            public int getCount() {
                return mResIds.length;
            }
        });
        viewPager.setPageTransformer(true,new ScaleTransformer());
    }
}